package com.venta.autopartes.dao;

import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;

import com.venta.autopartes.car.Currency;
import com.venta.autopartes.car.PaymentType;
import com.venta.autopartes.user.User;
import com.venta.autopartes.user.UserPrivilage;

public class CurrencyDAO extends BaseDAO{
	private static final String SELECT_CURRENCY="SELECT venau_currency_catalog_id as ID, venau_currency_catalog_name as NAME, venau_currency_catalog_symbol as SYMBOL FROM SGDLS_T_currency_catalog ORDER BY venau_currency_catalog_name";
	

	public static List<Currency> getCurrencyList(){
			List<Currency> currencyList= new ArrayList<Currency>();
			
			connection = com.venta.autopartes.utils.Connection.getConnection();
			try{
				preparedStatement = connection.prepareStatement(SELECT_CURRENCY);
				resultSet=preparedStatement.executeQuery();
				
				while (resultSet.next()) {
					Currency currency= new Currency(resultSet.getInt("ID"),resultSet.getString("NAME"),resultSet.getString("SYMBOL"));
					currencyList.add(currency);
				}
				
			}catch(SQLException sqlException){
				System.out.println("(Class)CurrencyDAO - (ErrorType)sqlException");
				sqlException.printStackTrace();
				try{
					connection.rollback();
				}catch(Exception exception){
					System.out.println("(Class)CurrencyDAO - (ErrorType)exception");
					exception.printStackTrace();
				}
			}finally{
				closeConnection();
			}
		
		return currencyList;
	}
	
	
}
